package model

import (
	"context"

	"gorm.io/gorm"
)

type defaultBlogModel struct {
	db *gorm.DB
}

func NewBlogModel(db *gorm.DB) BlogModel {
	return &defaultBlogModel{
		db: db,
	}
}

// BlogModel 接口
type BlogModel interface {
	Create(ctx context.Context, blog *BlogInfo) (uint, error)
	CreateImages(ctx context.Context, blogId uint, urls []string) error
	FindOne(ctx context.Context, id uint) (*BlogInfo, error)
	FindImages(ctx context.Context, blogId uint) ([]string, error)
	FindByUserID(ctx context.Context, userId int) ([]*BlogInfo, error)
	FindWithImages(ctx context.Context, id uint) (*BlogInfo, []string, error)
	IncrementReadCount(ctx context.Context, id uint, count int) error
	FindByUserIDWithPage(ctx context.Context, userId int, page, size int) ([]*BlogInfo, int64, error)
	FindWithPage(ctx context.Context, page, size int) ([]*BlogInfo, int64, error)
	IncrementLikeCount(ctx context.Context, id uint, count int) error
	CheckAuthor(ctx context.Context, id uint, userId int) (bool, error)
}
